home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include <windowsx.h>
- #include <dos.h>
- #include <string.h>
- #include <stdlib.h>
- #include <bios.h>
- #include "promo.h"
- #include "test.h"
-
- BOOL CheckForMCA(void);
- BOOL FindMatch (char *pszPat, char *buf, UINT cbBuf);
- /****************************************************************************
-
- FUNCTION : GetPCSystemMetrics
-
- PARAMETERS : LPPCSYSTEMMETRICS lpPCSysMetrics
-
- PURPOSE : calls the functions in this module and loads the
- results into a PCSYSTEMMETRICS table
-
- CALLS : MODULE
- cNumAudio
- cNumMIDI
- dwGetVersion
- dwGetPhysMem
- dwGetVirtMem
- fVgaCapable
- f256Capable
- dwFreeSpace
- GetHPLJ
- nGetCDROM
- wGetMSCDEXVer
- fTT2Installed
-
- RETURNS : void
-
- MESSAGES : none
-
- COMMENTS :
-
- HISTORY : 11/14/92 - created - denniscr
-
- ****************************************************************************/
-
- void PASCAL GetPCSystemMetrics(LPPCSYSTEMMETRICS lpPCSysMetrics)
- {
- LPINT lpDriveList = NULL;
- int nNumDrives = 0;
- int i;
- UINT uiOldSEM;
-
- if (lpPCSysMetrics)
- {
- uiOldSEM = SetErrorMode(SEM_FAILCRITICALERRORS);
-
- lpPCSysMetrics->wWINVer = LOWORD(dwGetVersion());
- lpPCSysMetrics->wDOSVer = HIWORD(dwGetVersion());
- lpPCSysMetrics->dwMemAvail = dwGetPhysMem() + dwGetVirtMem();
- lpPCSysMetrics->dwPhysicalMem = ExtMemCheck();
- lpPCSysMetrics->dwVirtualMem = dwGetVirtMem();
-
- lpPCSysMetrics->dwWinFlags = GetWinFlags();
-
-
- lpPCSysMetrics->fVGACapable = fVgaCapable();
- lpPCSysMetrics->f256Capable = f256Capable();
-
- //allocate memory for list of available fixed drives
- lpDriveList = (LPINT)GlobalAllocPtr(GHND, sizeof(int));
- //just look at fixed drives
- nNumDrives = EnumerateDrives(ED_FIXED, lpDriveList);
- //calculate each fixed drives free space
- for (i = 0; i < nNumDrives; i++, lpDriveList++)
- {
- //only look at harddrives
- lpPCSysMetrics->dwDiskFree[i] = dwDiskFreeSpace(*lpDriveList);
- }
- //free the list of available fixed drives
- GlobalFreePtr(lpDriveList);
-
- lpPCSysMetrics->fHPLJPresent = GetHPLJ();
- lpPCSysMetrics->nNumCDROM = nGetCDROM();
- lpPCSysMetrics->wNetType = WNetGetCaps(WNNC_NET_TYPE);
- lpPCSysMetrics->cNumAudio = cNumAudio();
- lpPCSysMetrics->cNumMIDI = cNumMIDI();
- lpPCSysMetrics->wMSCDEXVer = (lpPCSysMetrics->nNumCDROM) ? wGetMSCDEXVer() : 0;
-
- lpPCSysMetrics->fTT1Installed = fTTFInstalled(1);
- lpPCSysMetrics->fTT2Installed = fTTFInstalled(2);
-
-
- SetErrorMode(uiOldSEM);
- }
- return;
- }
-
- /****************************************************************************
-
- FUNCTION : cNumAudio
-
- PARAMETERS : void
-
- PURPOSE : retrieves the number of waveform output devices
- present in the system.
-
- CALLS : WINDOWS
- GetModuleHandle
- waveOutGetNumDevs
-
- RETURNS : number of wave output devices found
-
- MESSAGES : none
-
- COMMENTS : first checks to see if MMSYSTEM is loaded. So it works
- in 3.0 as well as 3.1
-
- HISTORY : - created - a-daveh
- 11/13/92 - modified - denniscr
-
- ****************************************************************************/
-
- int PASCAL cNumAudio(void)
- {
- UINT (FAR *lpfnwaveOutGetNumDevs) (void);
- HINSTANCE hInstWave;
- int nRet = 0;
- HANDLE hModule = GetModuleHandle("mmsystem.dll");
-
- if (hModule)
- {
- hInstWave = LoadLibrary("MMSYSTEM.DLL");
- if (hInstWave > HINSTANCE_ERROR)
- {
- (FARPROC) lpfnwaveOutGetNumDevs =
- GetProcAddress(hInstWave, "waveOutGetNumDevs");
- nRet = (*lpfnwaveOutGetNumDevs) ();
- FreeLibrary(hInstWave);
- }
- }
- return (nRet);
- }
-
- /****************************************************************************
-
- FUNCTION : cNumMIDI
-
- PARAMETERS : void
-
- PURPOSE : This function retrieves the number of MIDI output devices
- present in the system.
-
- CALLS : WINDOWS
- GetModuleHandle
- waveOutGetNumDevs
-
- RETURNS : number of midi output devices found
-
- MESSAGES : none
-
- COMMENTS : first checks to see if MMSYSTEM is loaded. So it works
- in 3.0 as well as 3.1
-
- HISTORY : - created - a-daveh
- 11/13/92 - modified - denniscr
-
- ****************************************************************************/
-
- int PASCAL cNumMIDI(void)
- {
- UINT (FAR *lpfnmidiOutGetNumDevs) (void);
- HINSTANCE hInstMIDI;
- int nRet = 0;
- HANDLE hModule = GetModuleHandle("mmsystem.dll");
-
- if (hModule)
- {
- hInstMIDI = LoadLibrary("MMSYSTEM.DLL");
- if (hInstMIDI > HINSTANCE_ERROR)
- {
- (FARPROC) lpfnmidiOutGetNumDevs =
- GetProcAddress(hInstMIDI, "midiOutGetNumDevs");
- nRet = (*lpfnmidiOutGetNumDevs) ();
- FreeLibrary(hInstMIDI);
- }
- }
- return (nRet);
-
- }
-
- /****************************************************************************
-
- FUNCTION : dwGetVersion
-
- PARAMETERS : void
-
- PURPOSE : The GetVersion function retrieves the current version
- numbers of the Windows and MS-DOS operation systems.
-
- CALLS : WINDOWS
- GetVersion
-
- RETURNS : major and minor version numbers of Windows and of MS-DOS.
-
- MESSAGES : none
-
- COMMENTS :
-
- HISTORY : - created - a-daveh
-
- ****************************************************************************/
-
- DWORD PASCAL dwGetVersion(void)
- {
- return (DWORD) GetVersion();
- }
-
- /****************************************************************************
-
- FUNCTION : fVgaCapable
-
- PARAMETERS : void
-
- PURPOSE : Determines if the system includes at least a VGA
-
- CALLS : WINDOWS
- GetDC
- GetDeviceCaps
- ReleaseDC
-
- RETURNS : BOOL - TRUE if VGA, FALSE if !VGA
-
- MESSAGES : none
-
- COMMENTS :
-
- HISTORY : - created - a-daveh
-
- ****************************************************************************/
-
-
- BOOL PASCAL fVgaCapable(void)
- {
- //get screen device context
- HDC hdc = GetDC(NULL);
-
- //is screen res. less then 640 x 480?
- if ((GetDeviceCaps(hdc, HORZRES) < 640) ||
- (GetDeviceCaps(hdc, VERTRES) < 480))
- {
- ReleaseDC(NULL, hdc);
- //if yes, then not VGA
- return FALSE;
- }
- else
- {
- ReleaseDC(NULL, hdc);
- //if no, then VGA
- return TRUE;
- }
- }
-
- /****************************************************************************
-
- FUNCTION : f256Capable
-
- PARAMETERS : void
-
- PURPOSE : determines if the screen dc is capable of at least 8bpp
-
- CALLS : WINDOWS
- GetDC
- GetDeviceCaps
- ReleaseDC
-
- RETURNS : number of wave output devices found
-
- MESSAGES : none
-
- COMMENTS : first checks to see if MMSYSTEM is loaded. So it works
- in 3.0 as well as 3.1
-
- HISTORY : - created - a-daveh
-
- ****************************************************************************/
-
-
- BOOL PASCAL f256Capable(void)
- {
- //get screen device context
- HDC hdc = GetDC(NULL);
-
- //is the screen dc capable of at least 8bpp?
- if ((GetDeviceCaps(hdc, NUMCOLORS) >= 256) ||
- (GetDeviceCaps(hdc, BITSPIXEL) >= 8))
- {
- ReleaseDC(NULL, hdc);
- //at least 8bpp
- return TRUE;
- }
- else
- {
- ReleaseDC(NULL, hdc);
- //less than 8bpp
- return FALSE;
- }
- }
-
- /****************************************************************************
-
- FUNCTION : dwDiskFreeSpace
-
- PARAMETERS : void
-
- PURPOSE : calculates the free space on the given drive
-
- CALLS : WINDOWS
- GetDriveType
- C
- _dos_getdiskfree
-
- RETURNS : amount of free disk space in KB
-
- MESSAGES : none
-
- COMMENTS :
-
- HISTORY : - created - a-daveh
- 11/14/92 - modified - denniscr
- 12/28/92 - modified to return the total space on the disk
- should generalize the function but no time!
-
- ****************************************************************************/
-
-
- DWORD PASCAL dwDiskFreeSpace(int drive)
- {
- struct diskfree_t diskspace;
- DWORD dwFree;
-
- //increment drive by one. The windows GetDriveType expects
- //A == 0, etc. whereas _dos_getdiskfree expects A == 1!!!
- if (_dos_getdiskfree(drive + 1, &diskspace) != 0)
- return ((DWORD)0);
-
- // dwFree = (DWORD)diskspace.avail_clusters *
- dwFree = (DWORD)diskspace.total_clusters *
- (DWORD)diskspace.sectors_per_cluster *
- (DWORD)diskspace.bytes_per_sector;
-
- dwFree = dwFree / 1024; /* return value in kilobytes */
-
- return (dwFree);
- }
-
- /****************************************************************************
-
- FUNCTION : GetHPLJ
-
- PARAMETERS : void
-
- PURPOSE : determine if the an HPLJ has been installed.
-
- CALLS : WINDOWS
- LocalAlloc
- LocalLock
- GetProfileString
- LocalUnlock
-
-
- RETURNS : int
-
- MESSAGES : none
-
- COMMENTS : just checks the WIN.INI folks!
-
- HISTORY : 11/12/92 - created - denniscr
-
- ****************************************************************************/
-
- BOOL PASCAL GetHPLJ()
- {
- LOCALHANDLE hDeviceMem;
- LPSTR lpsAllDevices;
- LPSTR lpsDevice;
-
- hDeviceMem = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, MAXALLDEVICELEN);
- lpsAllDevices = (LPSTR)LocalLock(hDeviceMem);
-
- GetProfileString("devices", NULL, "ERROR!", lpsAllDevices,
- MAXALLDEVICELEN);
- if (*lpsAllDevices)
- for (lpsDevice = lpsAllDevices; *lpsDevice != '\0';
- lpsDevice += lstrlen (lpsDevice)+1)
- {
-
- if ( _fstrstr( _fstrupr(lpsDevice),"LASERJET"))
- {
- LocalUnlock(hDeviceMem);
- LocalFree(hDeviceMem);
- return(TRUE);
- }
-
- //GetProfileString("devices", lpsDevice, "ERROR", szTemp, 255);
- //if ((lpsDriver = _fstrtok( szTemp, ",")))
- //{
- //if ( _fstrstr( _fstrupr(lpsDriver),"HPPCL"))
- //{
- // LocalUnlock(hDeviceMem);
- // LocalFree(hDeviceMem);
- // return(TRUE);
- //}
- //}
- }
-
- //free local memory
- LocalUnlock(hDeviceMem);
- LocalFree(hDeviceMem);
-
- //if we made it here we failed
- return(FALSE);
- }
-
-
- /****************************************************************************
-
- FUNCTION : fTTFInstalled
-
- PARAMETERS : void
-
- PURPOSE : test to see if any of the TT2 fontpack fonts are installed
-
- CALLS :
-
- RETURNS : BOOL
-
- MESSAGES : none
-
- COMMENTS :
-
- HISTORY : 11/19/92 - created - denniscr
-
- ****************************************************************************/
-
- BOOL PASCAL fTTFInstalled(int nPack)
- {
- int i;
- OFSTRUCT of;
- WORD wReturn;
- LPSTR lpSysDir;
-
- lpSysDir = (LPSTR)GlobalAllocPtr(GHND, 256 * sizeof(char));
-
- if (wReturn)
-
- for (i = 0; i < ((nPack == 1) ? NUMTT1FONTS : NUMTT2FONTS); i++)
- {
- wReturn = GetSystemDirectory(lpSysDir, (UINT)GlobalSize(GlobalPtrHandle(lpSysDir)));
-
- if (wReturn)
- {
- lstrcat(lpSysDir, (LPSTR)"\\");
- lstrcat(lpSysDir, ((nPack == 1) ? (LPSTR)TT1List[i].szFN : (LPSTR)TT2List[i].szFN));
- }
- else
- lstrcpy(lpSysDir, ((nPack == 1) ? (LPSTR)TT1List[i].szFN : (LPSTR)TT2List[i].szFN));
-
- if (HFILE_ERROR != OpenFile(lpSysDir, &of, OF_EXIST))
- {
- GlobalFreePtr(lpSysDir);
- return(TRUE);
- }
- }
- GlobalFreePtr(lpSysDir);
- return(FALSE);
- }
-
- /****************************************************************************
-
- FUNCTION : BitCount
-
- PARAMETERS :
-
- PURPOSE :
-
- CALLS :
-
- RETURNS : int
-
- MESSAGES : none
-
- COMMENTS :
-
- HISTORY : 12/12/92 - created - denniscr ala KR
-
- ****************************************************************************/
-
- int BitCount(DWORD dwBitField)
- {
- int nCount;
-
- for (nCount = 0; dwBitField != 0; dwBitField >>= 1)
- if (dwBitField & 1)
- nCount++;
-
- return (nCount);
- }
-
- /****************************************************************************
-
- FUNCTION : GetDOS_OEM
-
- PARAMETERS :
-
- PURPOSE :
-
- CALLS :
-
- RETURNS : int
-
- MESSAGES : none
-
- COMMENTS :
-
- HISTORY : 1/1/93 - created - denniscr
-
- ****************************************************************************/
-
- int GetDOS_OEM(WORD wDOSVer)
- {
-
- struct _find_t DTABuffer;
- int nResult = 0;
- char *env_OS;
- char szOS[25];
- HFILE hfReadFile;
- int nRet = 0;
- int cbBuf = 1024;
-
- if (HIBYTE(wDOSVer) == 0x0A || HIBYTE(wDOSVer) == 0x14)
- return (OS_OS2);
-
- nResult = _dos_findfirst("C:\\MSDOS.SYS", _A_HIDDEN | _A_SYSTEM, &DTABuffer);
-
- //if MSDOS.SYS is found then this is really MS_DOS
- if (!nResult)
- nRet = OS_MSDOS;
-
- else
- {
- hfReadFile = _lopen("C:\\IBMBIO.COM", READ);
-
- if (hfReadFile != HFILE_ERROR)
- {
- int cbRead;
- PBYTE pBuf;
-
- pBuf = (PBYTE) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, cbBuf);
-
- cbRead = _lread(hfReadFile, pBuf, cbBuf);
-
- if (cbRead)
- {
- if (FindMatch ("COMPAQ", (char *)pBuf, cbBuf))
- nRet = OS_MSDOS;
- else
- nRet = OS_PCDOS;
- }
-
- LocalFree((HLOCAL) pBuf);
- _lclose(hfReadFile);
- }
-
- //if the dos ver is 3.31 then be suspicious of
- //DRDOS. Take a look at the environment variables
- //if one of them is OS then see if it is DRDOS.
- //This will work if the user has not changed their
- //environment variables...
- //BTW - DRDOS froze their version number at 3.31
- if (wDOSVer == 0x031F)
- {
- env_OS = getenv( "OS" );
- strcpy(szOS, env_OS);
-
- if (strstr(env_OS, (NPSTR)"DRDOS"))
- nRet = OS_DRDOS;
- }
-
- }
- return( ((nRet) ? nRet : OS_MSDOS) );
- }
-
-
-
- /****************************************************************************
-
- FUNCTION : IsWFWCommDlg
-
- PARAMETERS :
-
- PURPOSE : This function returns non-zero if the machine is an
- MCA machine.
-
-
- CALLS :
-
- RETURNS : BOOL : TRUE if this is the COMMDLG from wfw
-
- MESSAGES : none
-
- COMMENTS : in addition to checking the net (multinet bit) this may
- be called to determine if this is WFW or not. A situation
- requiring this might be when wfw has been installed but
- no net drivers
-
- !!!THIS IS INCREDIBLY VERSION DEPENDENT!!!
-
- HISTORY : 1/22/93 - created - denniscr
- 1/28/93 - modified - denniscr
-
- ****************************************************************************/
-
- BOOL IsWFWCommDlg()
- {
- OFSTRUCT of;
- char szName[MAXPATHLEN];
-
- GetSystemDirectory((LPSTR)szName, (UINT)MAXPATHLEN);
- lstrcat((LPSTR)szName, (LPSTR)"\\WFWSETUP.CPL");
-
- if ( OpenFile((LPSTR)szName, &of, OF_EXIST) != HFILE_ERROR )
- return (TRUE);
- else
- return (FALSE);
-
- /*
-
- DWORD handle;
- DWORD dwSize = 0;
- BOOL fRet = FALSE;
- HINSTANCE hInstVer;
- char szName[MAXPATHLEN];
- DWORD (FAR *lpfnGetFileVersionInfoSize) (LPCSTR, DWORD FAR*);
-
- //this isn't working for some reason...
- //so...let's make it easy and just look for WFWSETUP.CPL
- //an file that is unique to WFW.
-
- if (lpPCSysMetrics->wWINVer == WIN31VER)
- {
- GetSystemDirectory((LPSTR)szName, (UINT)MAXPATHLEN);
- lstrcat((LPSTR)szName, (LPSTR)"\\COMMDLG.DLL");
-
- hInstVer = LoadLibrary("VER.DLL");
-
- if (hInstVer > HINSTANCE_ERROR)
- {
-
- (FARPROC) lpfnGetFileVersionInfoSize =
- GetProcAddress(hInstVer, "GetFileVersionInfoSize");
-
- dwSize = (*lpfnGetFileVersionInfoSize) ((LPCSTR)szName, (DWORD FAR *)&handle);
-
- if (dwSize)
- {
- LPVS_VERSION lpstrVffInfo;
- HANDLE hMem = NULL;
- BOOL (FAR *lpfnGetFileVersionInfo) (LPCSTR, DWORD, DWORD, void FAR*);
-
- (FARPROC) lpfnGetFileVersionInfo =
- GetProcAddress(hInstVer, "GetFileVersionInfo");
-
- //Get a block big enough to hold version info
- hMem = GlobalAlloc(GHND, dwSize);
-
- if (hMem)
- lpstrVffInfo = (LPVS_VERSION)GlobalLock(hMem);
-
- if (lpstrVffInfo)
- {
- // Get the info and fill in the pertinent dialog components
- if( (*lpfnGetFileVersionInfo) ((LPCSTR)szName, 0L, dwSize, lpstrVffInfo) )
- {
-
- if ( lpstrVffInfo->vffInfo.dwFileVersionLS == 2 )
- fRet = TRUE;
- }
- }
- else
- GlobalFree(hMem);
-
- if (hMem)
- {
- // free memory
- GlobalUnlock(hMem);
- GlobalFree(hMem);
- }
- }
-
- FreeLibrary(hInstVer);
- }
- }
- return (fRet);
- */
- }
-
-
- /****************************************************************************
- * FindMatch() - Searches a buffer for an asciiz string (case-insensitive)
- *
- * Entry
- * pszPat - Asciiz string to search for
- * buf - Buffer to search through
- * cbBuf - Length of buffer
- *
- * Exit
- * TRUE if match found, FALSE if not.
- *
- * Emoryh - 2/2/93
- ****************************************************************************/
- BOOL FindMatch (char *pszPat, char *buf, UINT cbBuf)
- {
- char *psz = pszPat;
- char *p;
-
- for (p=buf; p<&buf[cbBuf]; p++)
- {
-
- if (toupper(*p) == *psz)
- psz++; // Found match, so advance to next char
- else
- psz = pszPat; // No match, so reset back to beginning
-
- if (*psz == 0) // Reached end of pattern - we found it!
- return(TRUE);
- }
-
- // Didn't find pattern
- return(FALSE);
- }
-
-
-
-
-
-
-